
<template>
  <div class="updateanme_box">
    <topHeader>
      <div slot="left">
        <img src="./../../assets/img/return.png" alt="" @click="goMine">
      </div>
      <span slot="center">
        修改姓名
      </span>
    </topHeader>
    <div class="updateanme_box_con">
      <div class="updatepassword_box">
          <input  type="text" placeholder="请输入您的姓名" value="" v-model='userInfo.name' disabled/>
      </div>
      <div class="index_divide"></div>
      <div class="updatepassword_box">
          <input  type="text" placeholder="请输入您新姓名" value="" v-model='nameNew'/>
      </div>
      <div class="index_divide"></div>
      <div class="summit_btn" @click="makeSure">确定</div>
    </div>
  </div>
</template>

<script>
/* eslint-disable */
import { updateName } from '@/api/allapis'
import topHeader from './../../components/topHeader'
export default {
  data () {
    return {
      nameNew: ''
    }
  },

  components: {
    topHeader
  },

  computed: {
    userInfo(){
      return this.$store.state.user.uerInfo
    }
  },

  mounted () {},

  methods: {
    goMine () {
      this.$router.go(-1)
    },
    makeSure () {
      if (this.nameNew === '') {
        // alert('请输入您的新姓名')
        this.$vux.alert.show({
          title: '人人同行提示',
          content: '请输入您的新姓名',
          buttonText: '好的',
          hideOnBlur: true,
          maskZIndex: 100
        })
        return
      }
      updateName({ oldName: this.userInfo.name, newName: this.nameNew }).then(res => {
        // alert(res.data)
        this.$vux.alert.show({
          title: '人人同行提示',
          content: res.data,
          buttonText: '好的',
          hideOnBlur: true,
          maskZIndex: 100
        })
        this.$router.go(-1)
      })
    }
  }
}

</script>
<style lang='less' scoped>
@import url('./updatename.less');
</style>